base-create
Utility for npm init create-* scripts.
Note: If you're creating an initializer for monorepos, try base-create-monorepo
.
Example for a script called create-custom-babel
(run with npm init custom-babel my-app
), you could do:
#!/usr/bin/env node
const create = require("base-create");
const { name } = create({
dependencies: ["@babel/runtime"],
devDependencies: ["@babel/core", "@babel/plugin-transform-runtime"],
package: {
main: "dist/main.js",
scripts: {
build: "babel src --out-dir dist",
"build:watch": "npm run build -- --watch",
},
},
files: [
"src/index.js",
{
path: "src/hello.js",
contents: 'alert("hi")',
},
{
path: "README.md",
contents: ({ nameWithScope, nameWithoutScope, dirName }) =>
"# ${nameWithScope}",
},
],
commands: [],
config: {
scope: "@my-org",
},
skipGitignore: false,
skipReadme: false,
packages: [
{
name: "my-first-subpackage",
package: {
scripts: {
start: "node dist/first.js",
},
files: ["src/first.js"],
},
},
{
name: "my-second-subpackage",
package: {
scripts: {
start: "node dist/second.js",
},
files: ["src/second.js"],
},
},
],
});